var app = getApp();

Page({
    data: {
        mails: "",
        glo_is_load: !1,
        is_show_share: !1,
        btn_disabled: !1,
        submitIsLoading: !1,
        _card_info: [],
        mail_p: 0
    },
    onLoad: function(a) {
        var t = this, d = a.adid;
        t.setData({
            adId: d
        }), app.util.request({
            url: "entry/wxapp/GetCard",
            data: {
                m: "bbyscm_card"
            },
            success: function(a) {
                0 == a.data.errno && 0 == a.data.data && wx.showModal({
                    title: "你还没有创建名片，不能创建分会",
                    content: "你还没有创建名片，不能创建分会",
                    showCancel: !1,
                    success: function() {
                        wx.navigateTo({
                            url: "../edit/card-edit"
                        });
                    }
                }), t.setData({
                    _card_info: a.data.data,
                    cardid: a.data.data.id,
                    openid: a.data.data.openid,
                    username: a.data.data.username,
                    cardname: a.data.data.cardname
                });
            }
        }), app.util.request({
            url: "entry/wxapp/MailSetup",
            data: {
                m: "bbyscm_card"
            },
            success: function(a) {
                t.setData({
                    setup: a.data.data,
                    ontrial: a.data.data.ontrial,
                    mail_p: a.data.data.mail_p,
                    mail_pay: a.data.data.mail_pay
                });
            }
        }), app.globalData.hasLogin ? t.setData({
            userInfo: app.globalData.userInfo
        }) : app.util.getUserInfo(function(a) {
            app.globalData.hasLogin = !0, t.setData({
                userInfo: a
            }), app.globalData.userInfo = a;
        });
    },
    onReady: function() {},
    onShow: function() {
        var t = this;
        0 < t.data.adId && app.util.request({
            url: "entry/wxapp/GetMail",
            data: {
                m: "bbyscm_card",
                pstadid: t.data.adId
            },
            success: function(a) {
                0 == a.data.errno && t.setData({
                    mails: a.data.data,
                    aadid: a.data.data.id,
                    mail_name: a.data.data.mail_name,
                    mail_key: a.data.data.mail_key,
                    is_show: !1
                });
            }
        });
        var a = t.data.cardId, d = 1 == app.globalData.sysinfo.mobile_verify_status;
        t.setData({
            yzm_all_time: 60,
            cardid: a,
            _btn_disabled: d,
            avater: t.data.userInfo.memberInfo.avatar,
            mobile_verify_status: app.globalData.sysinfo.mobile_verify_status
        });
    },
    postCard: function(a) {
        var t = this;
        t.setData({
            btn_disabled: !0,
            submitIsLoading: !0
        }), JSON.stringify(a.detail.value);
        var d = a.detail.formId, i = t.data.adId, e = t.data.cardid, n = t.data.openid, s = t.data.cardname, o = a.detail.value.mail_name, l = t.data.cardid, r = "";
        r = 1 == t.data.mail_pay ? 0 : t.data.mail_p;
        var c = "";
        c = t.data.adId ? t.data.mail_key : r;
        var u = t.data.ontrial;
        if (!o) return wx.showModal({
            title: "提示",
            content: "请填写分会名称",
            showCancel: !1,
            success: function(a) {
                a.confirm, t.setData({
                    btn_disabled: !1,
                    submitIsLoading: !1
                });
            }
        }), !1;
        wx.showToast({
            title: "提交中...",
            icon: "loading",
            duration: 1e4
        }), app.util.request({
            url: "entry/wxapp/PostMyMails",
            data: {
                m: "bbyscm_card",
                mail_id: i,
                admin_cardid: e,
                admin_openid: n,
                admin_name: s,
                mail_name: o,
                mail_member: l,
                ontrial: u,
                mail_key: c,
                form_id: d
            },
            method: "POST",
            success: function(a) {
                0 == a.data.errno && wx.showModal({
                    title: "提示",
                    content: "提交成功",
                    showCancel: !1,
                    success: function(a) {
                        wx.navigateBack();
                    }
                });
            },
            fail: function(a) {
                wx.showModal({
                    title: "提示",
                    content: a.data.message,
                    showCancel: !1,
                    success: function(a) {
                        a.confirm && t.setData({
                            btn_disabled: !1,
                            submitIsLoading: !1
                        });
                    }
                });
            },
            complete: function() {
                wx.hideToast();
            }
        });
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});